﻿using EYCmsAdmin.Domain.Models;
using FluentNHibernate.Mapping;

namespace EYCmsAdmin.NHibernate.Mappings
{
    public class RoleMap : ClassMap<Role>
    {
        public RoleMap()
        {
            Table("[Role]");
            Id(m => m.Id).Column("RoleId").GeneratedBy.Identity();
            Map(m => m.Name).Column("RoleName").Length(50).Not.Nullable();
            HasManyToMany(m => m.Users).Table("UserToRole").ParentKeyColumn("RoleId").ChildKeyColumn("UserId").Cascade.None().Inverse();
        } 
    }
}